package com.optionexplorer.util;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;

public class NetUtils {

	
	/**
	 * Grabs the content of a page from the internet using URL.
	 * @param url
	 * @return
	 */
	public static StringBuilder getPageFromWeb(String urlStr) {
		
		StringBuilder sb = null;
		
		try {
			sb = new StringBuilder();			
			URL url = new URL(urlStr);
			String line = null;
			BufferedReader bufRead = 
				new BufferedReader(new InputStreamReader(url.openStream()));
			line = bufRead.readLine();
			while (line != null) {
				sb.append(line);
				line = bufRead.readLine();
			}
			bufRead.close();
		} catch (Exception ex) {
			ex.printStackTrace(System.out);
		}
		return sb;		
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
